/*
 * Copyright (c) 2020 hebeiyiliuba.com
 * All rights reserved.
 *
 */
package org.jeecg.common.constant.enums;

import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 预警消息
 *
 * @author duanlikao
 * @created 2020/12/22
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum MessageTypeEnum {
    MESSAGE_TYPE_UNKNOWN(0,"未知"),//
    MESSAGE_TYPE_SFZDQ_ERROR(10,"身份证已到期"),
    MESSAGE_TYPE_SFZDQ_WARNING(11,"身份证即将到期"),
    MESSAGE_TYPE_CYZGZDQ_ERROR(20,"从业资格证已到期"),//
    MESSAGE_TYPE_CYZGZDQ_WARNING(21,"从业资格证即将到期"),//
    MESSAGE_TYPE_JSZDQ_ERROR(30,"驾驶证已到期"),//
    MESSAGE_TYPE_JSZDQ_WARNING(31,"驾驶证即将到期"),//
    MESSAGE_TYPE_XSZDQ(40,"行驶证到期"),//
    MESSAGE_TYPE_YSZDQ_ERROR(50,"车辆道路运输证已到期"),//
    MESSAGE_TYPE_YSZDQ_WARNING(51,"车辆道路运输证即将到期"),//
    MESSAGE_TYPE_XKZDQ(60,"许可证到期"),
    MESSAGE_TYPE_SJQXJD(70,"司机取消接单"),//
    MESSAGE_TYPE_CLSH(80,"车辆审核"),//
    MESSAGE_TYPE_SJSH(90,"司机审核"),//
    MESSAGE_TYPE_HZSH(100,"货主审核"),//
    MESSAGE_TYPE_DDSH(110,"货源审核"),
    MESSAGE_TYPE_YDSH(120,"运单审核"),//
    MESSAGE_TYPE_CLWRW(130,"车辆未入网"),//
    MESSAGE_TYPE_YYZSDQ(140,"营业执照到期"),

    //Added start at 2024-07-15 for 增加业务流程的消息提醒类型
    MESSAGE_TYPE_RECEIVE(200,"已接单"),
    MESSAGE_TYPE_LOAD(210,"运单装货"),
    MESSAGE_TYPE_UNLOAD(220,"运单卸货"),
    MESSAGE_TYPE_SIGN(230,"运单签收"),
    MESSAGE_TYPE_CHECK(240,"运单对账"),
    MESSAGE_TYPE_PAY(250,"运单支付"),
    //Added end at 2024-07-15 for 增加业务流程的消息提醒类型
    ;


    private  int code;
    private  String msg;

    private static Map <Integer, MessageTypeEnum> codeMap = Maps.newHashMap();

    public int getCode() {
        return this.code;
    }

    public String getDesc() {
        return this.msg;
    }

    public static String getMsg(int code) {
        return codeMap.containsKey(code) ? codeMap.get(code).getDesc() : StringUtils.EMPTY;
    }

    public static boolean isValid(int code) {
        return codeMap.containsKey(code);
    }

    static {
        for (MessageTypeEnum status : MessageTypeEnum.values()) {
            codeMap.put(status.getCode(), status);
        }
    }

    public static MessageTypeEnum getMessageTypeEnumByVal(int code) {
        return Arrays.stream(MessageTypeEnum.values())
                .collect(Collectors.toMap(MessageTypeEnum::getCode, value -> value, (k1, k2) -> k2)).get(code);
    }
}
